1 Getting Started

Recently, twitch literature has begun characterizing twitch communities through twitch chat, viewership trends, and content but no known projects have used resources that exist outside of twitch to understand how twitch communities manifest and interact with one another.

One subreddit called LivestreamFail (LSF) is a dedicated subreddit where users share these twitch clips, general twitch news, and twitch drama.LivestreamFail is one way smaller streamers become noticed and is a platform that I can use to compare big and small communities. I’m interested in the ways emotes are used between smaller and larger communities because I believe emote meanings and sentiments are being actively redefined. This analysis will be split into an LSF part and Twitch emote-sentiment part.

This analysis will investigate users, posts, and comments (sentiment and topic) on r/LivestreamFail and then investigate the comment data and emote use from twitch clips that were featured in LSF posts.

unfold the code block to see which libraries are used

library(pacman)

p_load(tidyverse,
       tidytext,
       tm,
       lubridate,
       stringr, 
       text2vec,
       jsonlite,
       widyr,
       quanteda,
       visNetwork,
       igraph,
       ggraph,
       DT,
       ggthemes,
       readtext)

2 Reddit Data: r/LivestreamFail

LSF STUFF SHOULD GO HERE.

3 Twitch

3.1 Twitch: Data collection

tl;dr - twich dmca issues, streamer bans, and the app I used prevented me from downloading alot more data. Next time, I’ll work with the twitch api directly.

Reddit data was gathered using python and PRAW (Python Reddit API Wrapper) to gather recent data from r/LivestreamFail (October 2020). This resulted in over 900 reddit posts. This data was then used in R scrape links and document if the clips had chat available for download.

To actually download the twitch chat, I used application by lay295 and zigagrcar on github found here.

The Digital Millennium Copyright Act is affecting twitch in a big way.

Twitch is currenly in hot water with DMCA claims, and they are banning streamers for repeated streaming “copyrighted” songs. One method streamers use to combat this is by deleting their content shortly after it was broadcasted. This affected data collection since the collected twitch clips were being actively taken down.

This led to the collection of twitch chat from 227 links present in from the reddit posts.

3.2 Emote Data

R and Rselenium was used to scrape the emote data from FrankerFaceZ and BettertwitchTV. Roughly the Top 300 emotes used from each site was collected (emote name and link to image).


This is what a “busy” chat may look like. what chat looks like


3.2.1 Emote data table

This is a data table with the names and images of the top 600 emotes from both sites (BTTV & FFZ) combined.

bttv emotes need to be updated, also not sure if gif emotes work.

# https://i.stack.imgur.com/kLMaS.jpg

test<-emote_data %>% mutate("emote_image" = paste("<img src=", emote_link, sep = "")) %>% 
  mutate(emote_image = paste0(emote_image,' height="52"></img>',sep = "")) %>%  select(emote_name,emote_image)

datatable(test, escape = FALSE)



3.3 Descriptions of twitch chat

This chart shows us how many unique chat lines there are per streamer. This metric is useful for understanding which streamers may be getting the most attention during a point in time on LSF (October in this case). This metric should later be controlled for clip length, since longer clips offer more opprotunity for chat engagement.

data %>% group_by(streamer) %>%  count(sort = T)%>%
  head(n=10) %>% 
  ggplot(aes(x = reorder(streamer,-n), y = n))+
  geom_col()+
  theme_wsj(base_size = 12, color = "green")+
  theme(axis.text.x = element_text(size = 12, angle = 15,vjust = .55))+
  labs(title = "Which streamer has the most chats?")


This visualization show us the most active twitch chatters in our dataset. In a larger dataset, finding those high-interactcion chatters maybe useful for drawing links between communities or even creating a contributer badges on twith (like the founders badge).


# This creates a !%in% kind of deal
`%notin%` <- Negate(`%in%`)

data %>% group_by(user) %>% filter(user %notin% c("StreamElements","Streamlabs","Nightbot")) %>%  count(sort = T) %>%
  head(n=10)%>% 
  ggplot(aes(x = reorder(user,-n), y = n))+
  geom_col()+
  theme_wsj(base_size = 12, color = "green")+
  theme(axis.text.x = element_text(size = 8, angle = 15,vjust = .55),
        plot.title = element_text(size = 20))+
  labs(title = "Which user has the most chats?")

# Streamelements and streamlabs are bots. 


This plot will give us further insight in the the demographics of the communities of top 5 streamers. This shows the number accounts created by year for each member of the chat by streamer. As an example, one conclusion that may be drawn is that streamers forsen and Mizkif are not attracting new accounts (New user/ban evaders) to their channels. Another conclusion that may be drawn is that Trainwreckstv in 2018, attracted alot of new users, and perhaps played a significant role in bringing new users to twitch. I should investigate futher to understand what happened with train in 2018. This was perhaps his drama year with MitchJones (A popular WOW streamer) or The Speech.

data %>% 
  add_count(user,streamer) %>% 
  filter(n>1,user %notin% c("StreamElements","Streamlabs","Nightbot","Fossabot")) %>% 
  group_by(user) %>%
  add_count(n_distinct(streamer)) %>% 
  ungroup() %>% 
  top_n(`n_distinct(streamer)`, n = 2) %>% 
  arrange(desc(n)) %>%
  filter(n >=20) %>% 
  add_count(user,streamer,name = "#_chat_per_clip") %>% 
  ggplot(aes(x = user, y = `#_chat_per_clip`, fill = streamer))+
  geom_bar(position = "stack",stat = "identity")

data %>% filter(user ==  "hiteki") %>% 
  group_by(streamer) %>% count()
## # A tibble: 2 x 2
## # Groups:   streamer [2]
##   streamer     n
##   <chr>    <int>
## 1 Jerma985     3
## 2 MOONMOON    13
data %>% filter(user ==  "hiteki") %>% 
  summarise(count = n_distinct(streamer))
## # A tibble: 1 x 1
##   count
##   <int>
## 1     2


top_5_streamers <- data %>% group_by(streamer) %>% count(sort = T) %>% head(n=5) %>% distinct(streamer)


data %>% filter(streamer %in% top_5_streamers$streamer) %>% mutate(date_year = year(as.Date.character(date))) %>% group_by(date_year,streamer) %>% count(sort = T)%>%
  ggplot(aes(x = date_year, y = n, color = streamer)) + 
  geom_line(size = 2)+
  theme_wsj(base_size = 12, color = "green")+
  labs(title = "Streamer Communities: Account Creation Dates", subtitle = "Top 5 Streamers")+
  theme(plot.title = element_text(size = 15),plot.subtitle = element_text(size= 8),legend.title = element_blank(),legend.position = "bottom")


Tokens, bigrams and trigrams can give us insign into popular emotes/words combinations and spams that occur in these chats.


tokens <- data %>%
  unnest_tokens(word,body)%>% 
  filter(str_detect(word,"^[:alpha:]"))

tokens %>% glimpse(width = 50)
## Rows: 159,517
## Columns: 4
## $ user     <chr> "Humorous_Chimp", "mayodongs...
## $ date     <dttm> 2013-03-29 16:35:36, 2019-1...
## $ streamer <chr> "Jerma985", "Jerma985", "Jer...
## $ word     <chr> "omegalul", "out", "of", "mo...
tokens %>% group_by(word) %>% count(sort = T)%>%
  head(n=10) %>% 
  ggplot(aes(x= reorder(word,-n),y=n))+
  geom_col()+
  theme_wsj(base_size = 12, color = "green")+
  theme(axis.text.x = element_text(angle = 25))+
  labs(title ="Token Counts")

data %>%
  unnest_tokens(bigram,body,token = 'ngrams',n = 2)%>% 
  filter(str_detect(bigram,"^[:alpha:]")) %>% 
  group_by(bigram) %>% count(sort = T)%>%
  head(n=10) %>% 
  ggplot(aes(x= reorder(bigram,-n),y=n))+
  geom_col()+
  theme_wsj(base_size = 12, color = "green")+
  theme(axis.text.x = element_text(angle = 25,size = 9))+
  labs(title ="Bigram Counts")

data %>%
  unnest_tokens(trigram,body,token = 'ngrams',n = 3)%>% 
  filter(str_detect(trigram,"^[:alpha:]")) %>% 
  group_by(trigram) %>% count(sort = T)%>%
  head(n=10) %>% 
  ggplot(aes(x= reorder(trigram,-n),y=n))+
  geom_col()+
  theme_wsj(base_size = 12, color = "green")+
  theme(axis.text.x = element_text(angle = 25,size = 9))+
  labs(title ="trigram Counts")

As you can see, there are alot of duplicated words/phrases. I like to think of these as spams.

Some popular ones are “I was here Pogu I was here Pogu…” or “OMEGALUL OMEGALUL OMEGALUL OMEGALUL..”. One way to combat this is by stripping the chat text to only it’s unique words.

3.4 Comparisons of twitch chat

3.4.1 Word/Emote correlations

corpus_data <- readtext("C:/Users/macia/Documents/MSIA-19/Git/Reddit-and-Twitch/Data Collection/corpus_data.csv", text_field = 'text')
glimpse(corpus_data)
## Rows: 35,303
## Columns: 3
## $ doc_id   <chr> "corpus_data.csv.1", "corpus_data.csv.2", "corpus_data.csv...
## $ text     <chr> "+2", "OMEGALUL", "OUT OF MOJO", "DOOR OMEGALUL", "OMEGALU...
## $ streamer <chr> "Jerma985", "Jerma985", "Jerma985", "Jerma985", "Jerma985"...
corpus <- corpus(corpus_data)


dfm <- dfm(corpus, remove_punct=T)

# Select emotes
emotes = emote_data$emote_name

tags = dfm_select(dfm,pattern = emotes)

#tags

toptag = names(topfeatures(tags,30))

# These are the top emotes mentioned in the dataset from the list of popular bttv/ffz emotes
head(toptag)
## [1] "omegalul"  "pogu"      "lulw"      "kekw"      "pepelaugh" "clap"

3.4.2 Emote Combinations

tag_fcm <- fcm(tags)

toptags_fcm <- fcm_select(tag_fcm, pattern = toptag)
textplot_network(toptags_fcm,min_freeq = 0.1, edge_alpha = 0.7, edge_size = 5)

3.4.3 Emote/word combinations

tags = dfm_select(dfm, pattern = c("£","â","<","ó","ðÿ"),selection = "remove")

#tags

toptag = names(topfeatures(tags,20))


tag_fcm <- fcm(tags)

toptags_fcm <- fcm_select(tag_fcm, pattern = toptag)
textplot_network(toptags_fcm,min_freeq = 0.1, edge_alpha = 0.7, edge_size = 5)

3.4.4 Directed Bi-gram network

count_bigrams <- function(data) {
  data %>%
    unnest_tokens(bigram,"body", token = "ngrams", n = 2) %>%
    separate(bigram, c("word1", "word2"), sep = " ") %>%
    count(word1, word2, sort = TRUE)
}

visualize_bigrams <- function(bigrams) {
  set.seed(2020)
  a <- grid::arrow(type = "closed", length = unit(.15, "inches"))

  bigrams %>%
    graph_from_data_frame() %>%
    ggraph(layout = "fr") +
    geom_edge_link(aes(edge_alpha = n), show.legend = FALSE, arrow = a) +
    geom_node_point(color = "lightblue", size = 5) +
    geom_node_text(aes(label = name), vjust = 1, hjust = 1) +
    theme_void()
}

viz.bigrams <- data %>%
  count_bigrams()

# filter out rare combinations, as well as digits and produce graph
viz.bigrams %>%
  filter(n >70) %>%
  visualize_bigrams()
## Warning in graph_from_data_frame(.): In `d' `NA' elements were replaced with
## string "NA"


word_cors <- tokens %>%
  group_by(word) %>%
  filter(n() >= 10 ) %>%
  pairwise_cor(word, streamer, sort = T)#, sort = TRUE)

top_10 <-word_cors %>% mutate("streamer" = case_when(
  item2 == "trainwreckstv" ~ "trainwreckstv", # ahh, 
  item2 == "esfandtv" ~ "esfandtv",
  item2 == "forsen" ~ "forsen",
  item2 == "mizkif" ~ "mizkif",
  item2 == "ludwig" ~ "ludwig",
  item2 == "moonmoon" ~ "moonmoon",
  item2 == "xqcow" ~ "xqcow",
  item2 == "sykkuno" ~ "sykkuno",
  item2 == "vadikus007" ~ "vadikus007",
  item2 == "loltyler1" ~ "loltyler1",
  TRUE ~ "WHO?"
)) # there are 83 unique streamers in the dataset, we should filter this some how. Either top 20, or maybe with chats > 100. 
# Build a scraper that grabes the names of emotes for eache of the streamers?
#top_10 %>% group_by(streamer) %>% count() # strange numbers here, each streamer has same number?, because I filteer for top 10 above?
 # from 2 mil rows
 # to about 2k rows
test<-top_10 %>%
  mutate(contains_emote = case_when(item1 %in% emote_data$emote_name ~ 1, TRUE ~ 0)) %>% 
  filter(contains_emote == 1) %>% # filtering for only emotes!
  filter(streamer != "WHO?")%>%
  group_by(streamer) %>% top_n(10,wt = correlation)

streamers = c("trainwreckstv","esfandtv","forsen","mizkif","ludwig","moonmoon","xqcow","sykkuno","vadikus007","loltyler1")

emote_data_1 <- emote_data %>% select(emote_name,emote_link) %>% na.omit()

# TEST 2
test_2 <- test %>% left_join(emote_data_1, by = c("item1" = "emote_name"))
#-------

test <- test %>% graph_from_data_frame()
test_viz <- toVisNetworkData(test)

test_viz$nodes <- test_viz$nodes %>% mutate("group" = case_when(label %in% streamers ~ "Streamer",TRUE ~ "Emote"))
#test_viz checking the dataframe
visNetwork(nodes = test_viz$nodes, edges = test_viz$edges, main = "Emote correlation to Streamer")%>%
  visGroups(groupname = "Streamer", color = "green", shape = "square") %>%
  visGroups(groupname = "Emote", color = "blue")%>%
  visOptions(highlightNearest = list(enabled = T, hover = T))%>%
  visLegend()
#--------------------
test_2 <- test_2 %>% graph_from_data_frame()

test_viz_2 <- toVisNetworkData(test_2)


test_viz_2$nodes %>% distinct()
##                id          label
## 1    feelsokayman   feelsokayman
## 2          pogyou         pogyou
## 3        catdance       catdance
## 4    feelsrainman   feelsrainman
## 5          lulwut         lulwut
## 6        wutfacew       wutfacew
## 7        peepofat       peepofat
## 8          nopers         nopers
## 9       pepepains      pepepains
## 10          dance          dance
## 11          dicks          dicks
## 12          pepem          pepem
## 13        handsup        handsup
## 14          zulul          zulul
## 15       monkahmm       monkahmm
## 16      pepocheer      pepocheer
## 17      pepegapls      pepegapls
## 18       kkomrade       kkomrade
## 19        nodders        nodders
## 20        poggies        poggies
## 21           kapp           kapp
## 22       nymncorn       nymncorn
## 23     kissahomie     kissahomie
## 24       waitwhat       waitwhat
## 25        megalul        megalul
## 26         pugpls         pugpls
## 27         gachiw         gachiw
## 28  omegalaughing  omegalaughing
## 29       peeposhy       peeposhy
## 30          yappp          yappp
## 31        bboomer        bboomer
## 32          pphop          pphop
## 33          pepew          pepew
## 34         monaks         monaks
## 35         okayge         okayge
## 36         pepela         pepela
## 37          peped          peped
## 38       tridance       tridance
## 39      forsenpls      forsenpls
## 40 feelsstrongman feelsstrongman
## 41      okaychamp      okaychamp
## 42        pepepls        pepepls
## 43       peepopog       peepopog
## 44        trikool        trikool
## 45   forsenscoots   forsenscoots
## 46       headbang       headbang
## 47        nyanpls        nyanpls
## 48         okayeg         okayeg
## 49         pepege         pepege
## 50         zoomer         zoomer
## 51      widehardo      widehardo
## 52          pepes          pepes
## 53   pepemeltdown   pepemeltdown
## 54            ppl            ppl
## 55           oooo           oooo
## 56     sillychamp     sillychamp
## 57       gachipls       gachipls
## 58        teatime        teatime
## 59    feelsbadman    feelsbadman
## 60     gachihyper     gachihyper
## 61       donowall       donowall
## 62         kkonaw         kkonaw
## 63     painschamp     painschamp
## 64     monkaomega     monkaomega
## 65            rip            rip
## 66      peepoween      peepoween
## 67     ppoverheat     ppoverheat
## 68         pepega         pepega
## 69           woah           woah
## 70           pogo           pogo
## 71   widepeeposad   widepeeposad
## 72          hahaa          hahaa
## 73           bruh           bruh
## 74            oof            oof
## 75         catjam         catjam
## 76      gachibass      gachibass
## 77         hypers         hypers
## 78          xqcow          xqcow
## 79      loltyler1      loltyler1
## 80       moonmoon       moonmoon
## 81  trainwreckstv  trainwreckstv
## 82         forsen         forsen
## 83       esfandtv       esfandtv
## 84         mizkif         mizkif
## 85         ludwig         ludwig
## 86        sykkuno        sykkuno
test_viz_2$edges %>% distinct()
##               from            to correlation      streamer contains_emote
## 1     feelsokayman         xqcow   0.7114652         xqcow              1
## 2           pogyou     loltyler1   0.7027819     loltyler1              1
## 3         catdance      moonmoon   0.7027819      moonmoon              1
## 4     feelsrainman      moonmoon   0.7027819      moonmoon              1
## 5           lulwut      moonmoon   0.7027819      moonmoon              1
## 6         wutfacew trainwreckstv   0.7027819 trainwreckstv              1
## 7         peepofat trainwreckstv   0.7027819 trainwreckstv              1
## 8           nopers      moonmoon   0.6983225      moonmoon              1
## 9        pepepains        forsen   0.6937218        forsen              1
## 10           dance      esfandtv   0.6541667      esfandtv              1
## 11           dicks      esfandtv   0.6541667      esfandtv              1
## 12    feelsokayman        forsen   0.6406926        forsen              1
## 13           pepem        mizkif   0.6206329        mizkif              1
## 14         handsup         xqcow   0.6206329         xqcow              1
## 15           zulul        forsen   0.5888680        forsen              1
## 16        monkahmm        mizkif   0.5743590        mizkif              1
## 17       pepocheer     loltyler1   0.5702659     loltyler1              1
## 18       pepegapls trainwreckstv   0.5702659 trainwreckstv              1
## 19        kkomrade trainwreckstv   0.5702659 trainwreckstv              1
## 20           dance trainwreckstv   0.5702659 trainwreckstv              1
## 21           dicks trainwreckstv   0.5702659 trainwreckstv              1
## 22         nodders      moonmoon   0.5629142      moonmoon              1
## 23         handsup        forsen   0.5629142        forsen              1
## 24         poggies        ludwig   0.5592057        ludwig              1
## 25            kapp        mizkif   0.5181018        mizkif              1
## 26        nymncorn        forsen   0.5159300        forsen              1
## 27      kissahomie        mizkif   0.4935589        mizkif              1
## 28           dicks        mizkif   0.4935589        mizkif              1
## 29        monkahmm      esfandtv   0.4935589      esfandtv              1
## 30        monkahmm       sykkuno   0.4935589       sykkuno              1
## 31       pepepains         xqcow   0.4935589         xqcow              1
## 32        waitwhat trainwreckstv   0.4907684 trainwreckstv              1
## 33         megalul trainwreckstv   0.4907684 trainwreckstv              1
## 34         megalul trainwreckstv   0.4907684 trainwreckstv              1
## 35          pugpls      moonmoon   0.4876543      moonmoon              1
## 36          gachiw      moonmoon   0.4876543      moonmoon              1
## 37   omegalaughing      moonmoon   0.4876543      moonmoon              1
## 38        peeposhy      moonmoon   0.4876543      moonmoon              1
## 39           yappp      moonmoon   0.4876543      moonmoon              1
## 40         bboomer      moonmoon   0.4876543      moonmoon              1
## 41           pphop      moonmoon   0.4876543      moonmoon              1
## 42           pepew      moonmoon   0.4876543      moonmoon              1
## 43          monaks      moonmoon   0.4876543      moonmoon              1
## 44          okayge      moonmoon   0.4876543      moonmoon              1
## 45          pepela        ludwig   0.4746835        ludwig              1
## 46           peped        mizkif   0.4698137        mizkif              1
## 47        tridance        mizkif   0.4698137        mizkif              1
## 48       forsenpls        forsen   0.4610390        forsen              1
## 49  feelsstrongman        mizkif   0.4481860        mizkif              1
## 50       okaychamp      esfandtv   0.4444625      esfandtv              1
## 51         pepepls     loltyler1   0.4361696     loltyler1              1
## 52        nymncorn     loltyler1   0.4361696     loltyler1              1
## 53        peepopog trainwreckstv   0.4361696 trainwreckstv              1
## 54         trikool trainwreckstv   0.4361696 trainwreckstv              1
## 55    forsenscoots         xqcow   0.4361696         xqcow              1
## 56        headbang         xqcow   0.4361696         xqcow              1
## 57         nyanpls         xqcow   0.4361696         xqcow              1
## 58          okayeg         xqcow   0.4361696         xqcow              1
## 59          pepege         xqcow   0.4361696         xqcow              1
## 60          zoomer         xqcow   0.4361696         xqcow              1
## 61       widehardo        mizkif   0.4320543        mizkif              1
## 62           pepes        ludwig   0.4158886        ludwig              1
## 63    pepemeltdown        ludwig   0.4158886        ludwig              1
## 64             ppl        ludwig   0.4158886        ludwig              1
## 65            oooo         xqcow   0.4158886         xqcow              1
## 66      sillychamp         xqcow   0.4158886         xqcow              1
## 67        gachipls         xqcow   0.4158886         xqcow              1
## 68           zulul         xqcow   0.4158886         xqcow              1
## 69         teatime        forsen   0.4144122        forsen              1
## 70     feelsbadman      esfandtv   0.4123106      esfandtv              1
## 71      gachihyper        mizkif   0.4074748        mizkif              1
## 72        donowall      esfandtv   0.4057949      esfandtv              1
## 73          kkonaw      esfandtv   0.4057949      esfandtv              1
## 74      painschamp      esfandtv   0.4057949      esfandtv              1
## 75            kapp      esfandtv   0.3962717      esfandtv              1
## 76    forsenscoots        forsen   0.3956059        forsen              1
## 77          lulwut        forsen   0.3956059        forsen              1
## 78        headbang        forsen   0.3956059        forsen              1
## 79         nyanpls        forsen   0.3956059        forsen              1
## 80          okayeg        forsen   0.3956059        forsen              1
## 81          pepege        forsen   0.3956059        forsen              1
## 82           pepem      esfandtv   0.3905059      esfandtv              1
## 83          gachiw      esfandtv   0.3905059      esfandtv              1
## 84   omegalaughing      esfandtv   0.3905059      esfandtv              1
## 85         bboomer      esfandtv   0.3905059      esfandtv              1
## 86        wutfacew      esfandtv   0.3905059      esfandtv              1
## 87        peepofat      esfandtv   0.3905059      esfandtv              1
## 88      monkaomega       sykkuno   0.3905059       sykkuno              1
## 89          pogyou       sykkuno   0.3905059       sykkuno              1
## 90             rip       sykkuno   0.3815603       sykkuno              1
## 91       peepoween       sykkuno   0.3742029       sykkuno              1
## 92      ppoverheat        ludwig   0.3716412        ludwig              1
## 93           peped     loltyler1   0.3638739     loltyler1              1
## 94          pepega       sykkuno   0.3554093       sykkuno              1
## 95            woah        ludwig   0.3493214        ludwig              1
## 96            pogo        ludwig   0.3493214        ludwig              1
## 97    widepeeposad       sykkuno   0.3476739       sykkuno              1
## 98       peepoween     loltyler1   0.3381261     loltyler1              1
## 99           hahaa     loltyler1   0.3381261     loltyler1              1
## 100          hahaa     loltyler1   0.3381261     loltyler1              1
## 101          hahaa     loltyler1   0.3381261     loltyler1              1
## 102     painschamp        ludwig   0.3365734        ludwig              1
## 103           bruh        ludwig   0.3331710        ludwig              1
## 104            oof       sykkuno   0.3249166       sykkuno              1
## 105       kkomrade       sykkuno   0.3083333       sykkuno              1
## 106      pepocheer       sykkuno   0.3083333       sykkuno              1
## 107        poggies       sykkuno   0.3083333       sykkuno              1
## 108         catjam     loltyler1   0.2983696     loltyler1              1
## 109      gachibass     loltyler1   0.2983696     loltyler1              1
## 110         hypers     loltyler1   0.2983696     loltyler1              1
##                                         emote_link
## 1   https://cdn.frankerfacez.com/emoticon/145947/1
## 2   https://cdn.frankerfacez.com/emoticon/297232/1
## 3                                             <NA>
## 4                                             <NA>
## 5   https://cdn.frankerfacez.com/emoticon/249979/1
## 6   https://cdn.frankerfacez.com/emoticon/168065/1
## 7   https://cdn.frankerfacez.com/emoticon/288800/1
## 8                                             <NA>
## 9   https://cdn.frankerfacez.com/emoticon/227992/1
## 10                                            <NA>
## 11   https://cdn.frankerfacez.com/emoticon/19972/1
## 12  https://cdn.frankerfacez.com/emoticon/145947/1
## 13  https://cdn.frankerfacez.com/emoticon/362432/1
## 14  https://cdn.frankerfacez.com/emoticon/229760/1
## 15                                            <NA>
## 16  https://cdn.frankerfacez.com/emoticon/240746/1
## 17                                            <NA>
## 18                                            <NA>
## 19  https://cdn.frankerfacez.com/emoticon/145916/1
## 20                                            <NA>
## 21   https://cdn.frankerfacez.com/emoticon/19972/1
## 22                                            <NA>
## 23  https://cdn.frankerfacez.com/emoticon/229760/1
## 24  https://cdn.frankerfacez.com/emoticon/257284/1
## 25  https://cdn.frankerfacez.com/emoticon/218860/1
## 26                                            <NA>
## 27  https://cdn.frankerfacez.com/emoticon/298316/1
## 28   https://cdn.frankerfacez.com/emoticon/19972/1
## 29  https://cdn.frankerfacez.com/emoticon/240746/1
## 30  https://cdn.frankerfacez.com/emoticon/240746/1
## 31  https://cdn.frankerfacez.com/emoticon/227992/1
## 32   https://cdn.frankerfacez.com/emoticon/47416/1
## 33  https://cdn.frankerfacez.com/emoticon/419215/1
## 34  https://cdn.frankerfacez.com/emoticon/119959/1
## 35                                            <NA>
## 36                                            <NA>
## 37                                            <NA>
## 38  https://cdn.frankerfacez.com/emoticon/448771/1
## 39                                            <NA>
## 40                                            <NA>
## 41                                            <NA>
## 42  https://cdn.frankerfacez.com/emoticon/232677/1
## 43  https://cdn.frankerfacez.com/emoticon/184836/1
## 44  https://cdn.frankerfacez.com/emoticon/410314/1
## 45  https://cdn.frankerfacez.com/emoticon/355871/1
## 46  https://cdn.frankerfacez.com/emoticon/319304/1
## 47                                            <NA>
## 48                                            <NA>
## 49   https://cdn.frankerfacez.com/emoticon/64210/1
## 50  https://cdn.frankerfacez.com/emoticon/280358/1
## 51                                            <NA>
## 52                                            <NA>
## 53  https://cdn.frankerfacez.com/emoticon/302472/1
## 54  https://cdn.frankerfacez.com/emoticon/375269/1
## 55  https://cdn.frankerfacez.com/emoticon/265650/1
## 56                                            <NA>
## 57                                            <NA>
## 58  https://cdn.frankerfacez.com/emoticon/438696/1
## 59  https://cdn.frankerfacez.com/emoticon/341610/1
## 60  https://cdn.frankerfacez.com/emoticon/316077/1
## 61  https://cdn.frankerfacez.com/emoticon/309114/1
## 62                                            <NA>
## 63                                            <NA>
## 64  https://cdn.frankerfacez.com/emoticon/229544/1
## 65                                            <NA>
## 66  https://cdn.frankerfacez.com/emoticon/368150/1
## 67                                            <NA>
## 68                                            <NA>
## 69                                            <NA>
## 70   https://cdn.frankerfacez.com/emoticon/33355/1
## 71  https://cdn.frankerfacez.com/emoticon/196406/1
## 72                                            <NA>
## 73  https://cdn.frankerfacez.com/emoticon/229486/1
## 74  https://cdn.frankerfacez.com/emoticon/263297/1
## 75  https://cdn.frankerfacez.com/emoticon/218860/1
## 76  https://cdn.frankerfacez.com/emoticon/265650/1
## 77  https://cdn.frankerfacez.com/emoticon/249979/1
## 78                                            <NA>
## 79                                            <NA>
## 80  https://cdn.frankerfacez.com/emoticon/438696/1
## 81  https://cdn.frankerfacez.com/emoticon/341610/1
## 82  https://cdn.frankerfacez.com/emoticon/362432/1
## 83                                            <NA>
## 84                                            <NA>
## 85                                            <NA>
## 86  https://cdn.frankerfacez.com/emoticon/168065/1
## 87  https://cdn.frankerfacez.com/emoticon/288800/1
## 88  https://cdn.frankerfacez.com/emoticon/167431/1
## 89  https://cdn.frankerfacez.com/emoticon/297232/1
## 90  https://cdn.frankerfacez.com/emoticon/164177/1
## 91                                            <NA>
## 92                                            <NA>
## 93  https://cdn.frankerfacez.com/emoticon/319304/1
## 94  https://cdn.frankerfacez.com/emoticon/243789/1
## 95                                            <NA>
## 96  https://cdn.frankerfacez.com/emoticon/401202/1
## 97  https://cdn.frankerfacez.com/emoticon/303899/1
## 98                                            <NA>
## 99   https://cdn.frankerfacez.com/emoticon/57611/1
## 100 https://cdn.frankerfacez.com/emoticon/285676/1
## 101 https://cdn.frankerfacez.com/emoticon/144811/1
## 102 https://cdn.frankerfacez.com/emoticon/263297/1
## 103 https://cdn.frankerfacez.com/emoticon/294111/1
## 104 https://cdn.frankerfacez.com/emoticon/261564/1
## 105 https://cdn.frankerfacez.com/emoticon/145916/1
## 106                                           <NA>
## 107 https://cdn.frankerfacez.com/emoticon/257284/1
## 108                                           <NA>
## 109 https://cdn.frankerfacez.com/emoticon/273779/1
## 110 https://cdn.frankerfacez.com/emoticon/236895/1
test_viz_2$nodes <- test_viz_2$nodes %>% mutate("group" = case_when(label %in% streamers ~ "Streamer",TRUE ~ "Emote"),
                                                "shape" = "image")

#test_viz_2$nodes <-
test_viz_2$nodes<-test_viz_2$nodes %>% left_join(test_viz_2$edges, by = c('id' = 'from')) %>% select(id,label,group,shape,emote_link) %>% rename(image = emote_link) %>% distinct(id, .keep_all = T)
test_viz_2$nodes %>% distinct()
##                id          label    group shape
## 1    feelsokayman   feelsokayman    Emote image
## 2          pogyou         pogyou    Emote image
## 3        catdance       catdance    Emote image
## 4    feelsrainman   feelsrainman    Emote image
## 5          lulwut         lulwut    Emote image
## 6        wutfacew       wutfacew    Emote image
## 7        peepofat       peepofat    Emote image
## 8          nopers         nopers    Emote image
## 9       pepepains      pepepains    Emote image
## 10          dance          dance    Emote image
## 11          dicks          dicks    Emote image
## 12          pepem          pepem    Emote image
## 13        handsup        handsup    Emote image
## 14          zulul          zulul    Emote image
## 15       monkahmm       monkahmm    Emote image
## 16      pepocheer      pepocheer    Emote image
## 17      pepegapls      pepegapls    Emote image
## 18       kkomrade       kkomrade    Emote image
## 19        nodders        nodders    Emote image
## 20        poggies        poggies    Emote image
## 21           kapp           kapp    Emote image
## 22       nymncorn       nymncorn    Emote image
## 23     kissahomie     kissahomie    Emote image
## 24       waitwhat       waitwhat    Emote image
## 25        megalul        megalul    Emote image
## 26         pugpls         pugpls    Emote image
## 27         gachiw         gachiw    Emote image
## 28  omegalaughing  omegalaughing    Emote image
## 29       peeposhy       peeposhy    Emote image
## 30          yappp          yappp    Emote image
## 31        bboomer        bboomer    Emote image
## 32          pphop          pphop    Emote image
## 33          pepew          pepew    Emote image
## 34         monaks         monaks    Emote image
## 35         okayge         okayge    Emote image
## 36         pepela         pepela    Emote image
## 37          peped          peped    Emote image
## 38       tridance       tridance    Emote image
## 39      forsenpls      forsenpls    Emote image
## 40 feelsstrongman feelsstrongman    Emote image
## 41      okaychamp      okaychamp    Emote image
## 42        pepepls        pepepls    Emote image
## 43       peepopog       peepopog    Emote image
## 44        trikool        trikool    Emote image
## 45   forsenscoots   forsenscoots    Emote image
## 46       headbang       headbang    Emote image
## 47        nyanpls        nyanpls    Emote image
## 48         okayeg         okayeg    Emote image
## 49         pepege         pepege    Emote image
## 50         zoomer         zoomer    Emote image
## 51      widehardo      widehardo    Emote image
## 52          pepes          pepes    Emote image
## 53   pepemeltdown   pepemeltdown    Emote image
## 54            ppl            ppl    Emote image
## 55           oooo           oooo    Emote image
## 56     sillychamp     sillychamp    Emote image
## 57       gachipls       gachipls    Emote image
## 58        teatime        teatime    Emote image
## 59    feelsbadman    feelsbadman    Emote image
## 60     gachihyper     gachihyper    Emote image
## 61       donowall       donowall    Emote image
## 62         kkonaw         kkonaw    Emote image
## 63     painschamp     painschamp    Emote image
## 64     monkaomega     monkaomega    Emote image
## 65            rip            rip    Emote image
## 66      peepoween      peepoween    Emote image
## 67     ppoverheat     ppoverheat    Emote image
## 68         pepega         pepega    Emote image
## 69           woah           woah    Emote image
## 70           pogo           pogo    Emote image
## 71   widepeeposad   widepeeposad    Emote image
## 72          hahaa          hahaa    Emote image
## 73           bruh           bruh    Emote image
## 74            oof            oof    Emote image
## 75         catjam         catjam    Emote image
## 76      gachibass      gachibass    Emote image
## 77         hypers         hypers    Emote image
## 78          xqcow          xqcow Streamer image
## 79      loltyler1      loltyler1 Streamer image
## 80       moonmoon       moonmoon Streamer image
## 81  trainwreckstv  trainwreckstv Streamer image
## 82         forsen         forsen Streamer image
## 83       esfandtv       esfandtv Streamer image
## 84         mizkif         mizkif Streamer image
## 85         ludwig         ludwig Streamer image
## 86        sykkuno        sykkuno Streamer image
##                                             image
## 1  https://cdn.frankerfacez.com/emoticon/145947/1
## 2  https://cdn.frankerfacez.com/emoticon/297232/1
## 3                                            <NA>
## 4                                            <NA>
## 5  https://cdn.frankerfacez.com/emoticon/249979/1
## 6  https://cdn.frankerfacez.com/emoticon/168065/1
## 7  https://cdn.frankerfacez.com/emoticon/288800/1
## 8                                            <NA>
## 9  https://cdn.frankerfacez.com/emoticon/227992/1
## 10                                           <NA>
## 11  https://cdn.frankerfacez.com/emoticon/19972/1
## 12 https://cdn.frankerfacez.com/emoticon/362432/1
## 13 https://cdn.frankerfacez.com/emoticon/229760/1
## 14                                           <NA>
## 15 https://cdn.frankerfacez.com/emoticon/240746/1
## 16                                           <NA>
## 17                                           <NA>
## 18 https://cdn.frankerfacez.com/emoticon/145916/1
## 19                                           <NA>
## 20 https://cdn.frankerfacez.com/emoticon/257284/1
## 21 https://cdn.frankerfacez.com/emoticon/218860/1
## 22                                           <NA>
## 23 https://cdn.frankerfacez.com/emoticon/298316/1
## 24  https://cdn.frankerfacez.com/emoticon/47416/1
## 25 https://cdn.frankerfacez.com/emoticon/419215/1
## 26                                           <NA>
## 27                                           <NA>
## 28                                           <NA>
## 29 https://cdn.frankerfacez.com/emoticon/448771/1
## 30                                           <NA>
## 31                                           <NA>
## 32                                           <NA>
## 33 https://cdn.frankerfacez.com/emoticon/232677/1
## 34 https://cdn.frankerfacez.com/emoticon/184836/1
## 35 https://cdn.frankerfacez.com/emoticon/410314/1
## 36 https://cdn.frankerfacez.com/emoticon/355871/1
## 37 https://cdn.frankerfacez.com/emoticon/319304/1
## 38                                           <NA>
## 39                                           <NA>
## 40  https://cdn.frankerfacez.com/emoticon/64210/1
## 41 https://cdn.frankerfacez.com/emoticon/280358/1
## 42                                           <NA>
## 43 https://cdn.frankerfacez.com/emoticon/302472/1
## 44 https://cdn.frankerfacez.com/emoticon/375269/1
## 45 https://cdn.frankerfacez.com/emoticon/265650/1
## 46                                           <NA>
## 47                                           <NA>
## 48 https://cdn.frankerfacez.com/emoticon/438696/1
## 49 https://cdn.frankerfacez.com/emoticon/341610/1
## 50 https://cdn.frankerfacez.com/emoticon/316077/1
## 51 https://cdn.frankerfacez.com/emoticon/309114/1
## 52                                           <NA>
## 53                                           <NA>
## 54 https://cdn.frankerfacez.com/emoticon/229544/1
## 55                                           <NA>
## 56 https://cdn.frankerfacez.com/emoticon/368150/1
## 57                                           <NA>
## 58                                           <NA>
## 59  https://cdn.frankerfacez.com/emoticon/33355/1
## 60 https://cdn.frankerfacez.com/emoticon/196406/1
## 61                                           <NA>
## 62 https://cdn.frankerfacez.com/emoticon/229486/1
## 63 https://cdn.frankerfacez.com/emoticon/263297/1
## 64 https://cdn.frankerfacez.com/emoticon/167431/1
## 65 https://cdn.frankerfacez.com/emoticon/164177/1
## 66                                           <NA>
## 67                                           <NA>
## 68 https://cdn.frankerfacez.com/emoticon/243789/1
## 69                                           <NA>
## 70 https://cdn.frankerfacez.com/emoticon/401202/1
## 71 https://cdn.frankerfacez.com/emoticon/303899/1
## 72  https://cdn.frankerfacez.com/emoticon/57611/1
## 73 https://cdn.frankerfacez.com/emoticon/294111/1
## 74 https://cdn.frankerfacez.com/emoticon/261564/1
## 75                                           <NA>
## 76 https://cdn.frankerfacez.com/emoticon/273779/1
## 77 https://cdn.frankerfacez.com/emoticon/236895/1
## 78                                           <NA>
## 79                                           <NA>
## 80                                           <NA>
## 81                                           <NA>
## 82                                           <NA>
## 83                                           <NA>
## 84                                           <NA>
## 85                                           <NA>
## 86                                           <NA>
#test_viz_2 checking the dataframe
visNetwork(nodes = test_viz_2$nodes, edges = test_viz_2$edges, main = "Emote correlation to Streamer")%>%
  visGroups(groupname = "Streamer", color = "green", shape = "square") %>%
  visGroups(groupname = "Emote", color = "blue")%>%
  visOptions(highlightNearest = list(enabled = T, hover = T))%>%
  visLegend()

# delete me at some point

test<-top_10 %>%
  mutate(contains_emote = case_when(item1 %in% emote_data$emote_name ~ 1, TRUE ~ 0)) %>% 
  filter(contains_emote == 1) %>% # filtering for only emotes!
  filter(streamer != "WHO?")%>%
  inner_join(emote_data, by = c("item1" = "emote_name")) %>% 
  filter(emote_link != is.na(emote_link)) %>% 
  group_by(streamer) %>% top_n(10,wt = correlation) %>%
  graph_from_data_frame()# %>%
 # ggraph(layout = "fr") +
 # geom_edge_link(aes(edge_alpha = correlation), show.legend = FALSE) +
 #  geom_node_point(aes(color = streamer), size = 5) +
 #  geom_node_text(aes(label = name), repel = TRUE) +
 #  theme_void()

streamers = c("trainwreckstv","esfandtv","forsen","mizkif","ludwig","moonmoon","xqcow","sykkuno","vadikus007","loltyler1")

test_viz <- toVisNetworkData(test)

test_viz$edges
test_viz$nodes
test_viz$nodes <- test_viz$nodes %>% 
  mutate("group" = case_when(label %in% streamers ~ "Streamer",TRUE ~ "Emote"),
                                            "shape" = "image") %>% 
  inner_join(test_viz$edges, by = c("id" = "from")) %>%
  select(c(id,label,group,shape,emote_link))%>%
  mutate("image" = magick::image_read(emote_link))



#test_viz checking the dataframe
visNetwork(nodes = test_viz$nodes, edges = test_viz$edges, main = "Emote correlation to Streamer")%>%
  visGroups(groupname = "Streamer", color = "green", shape = "square") %>%
  visGroups(groupname = "Emote", color = "blue")%>%
  visOptions(highlightNearest = list(enabled = T, hover = T))%>%
  visLegend()